# Maintainer: David Runge <dvzrv@archlinux.org>
# Contributor: Gaetan Bisson <bisson@archlinux.org>
# Contributor: Giovanni Scafora <giovanni@archlinux.org>
# Contributor: dorphell <dorphell@archlinux.org>

pkgname=tcpdump
pkgver=4.99.4
pkgrel=1
pkgdesc='Powerful command-line packet analyzer'
url="https://www.tcpdump.org/"
arch=(loong64 x86_64)
license=(BSD)
depends=(glibc)
makedepends=(
  cmake
  libpcap
  libcap-ng
  openssl
)
source=(https://www.tcpdump.org/release/$pkgname-$pkgver.tar.gz{,.sig})
sha512sums=('cb51e19574707d07c0de90dd4c301955897f2c9f2a69beb7162c08f59189f55625346d1602c8d66ab2b4c626ea4b0df1f08ed8734d2d7f536d0a7840c2d6d8df'
            'SKIP')
b2sums=('f100e10774574ef04a770bc30d4e2d06fd0f1f16a7b2c88848be6e8290cc4838666ff378d9f78fdc418f4ffab9716a11214edc3588c292cb5ff39636cd7cfd2d'
        'SKIP')
validpgpkeys=('1F166A5742ABB9E0249A8D30E089DEF1D9C15D0D') # The Tcpdump Group (Package signing key) <release@tcpdump.org>

build() {
  local cmake_options=(
    -DCMAKE_INSTALL_PREFIX=/usr
    -DCMAKE_BUILD_TYPE=None
    -Wno-dev
    -B build
    -S $pkgname-$pkgver
  )

  cmake "${cmake_options[@]}"
  cmake --build build --verbose
}

check() {
  make VERBOSE=1 check -C build
}

package() {
  depends+=(
    libpcap libpcap.so
    libcap-ng libcap-ng.so
    openssl libcrypto.so
  )

  DESTDIR="$pkgdir" cmake --install build
  install -vDm 644 $pkgname-$pkgver/LICENSE -t "$pkgdir/usr/share/licenses/$pkgname/"
}
